<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.io.*,java.util.*" %>
<html>
<html>
<head>
    <title>网站访问量统计</title>
</head>
<body>
<%
    // 1.获取页面总访问量
    Integer hitsCount = (Integer) application.getAttribute("hitCounter");

    // 2.判断访问量
    // 2.1如果访问量为null或零，则是首次访问，hitsCount置为1
    // 2.2如果访问量不为null或零，则hitsCount+1后，输出hitsCount
    if (hitsCount == null || hitsCount == 0) {
        hitsCount = 1;
    } else {
        hitsCount += 1;
    }

    // 3.application内置对象中存储键为hitCounter，值为总访问量
    application.setAttribute("hitCounter", hitsCount);
    request.getSession().setAttribute("hitsCount",hitsCount);
%>
</body>
</html>